using System;
using CStock;
using CUtil;
using System.Diagnostics;
namespace CStock
{
	
	//[System.Xml.Serialization.XmlRootAttribute("TradeCondition", Namespace="", IsNullable=false)]
    public class TradeEconomyProfileFactory : Factory, ITradeEconomyProfileFactory
    {

       
        ITradeEconomyProfile tradeEcomonomyProfile ;

        public TradeEconomyProfileFactory()
        {
            tradeEcomonomyProfile = new TradeEconomyProfile();
            tradeEcomonomyProfile.ID = "CentralBank";

            this.stockObjectBase = tradeEcomonomyProfile as StockObjectBase;

           
        }

      

        public override bool DeSerialize()
        {
            if (base.DeSerialize())
            {
                this.tradeEcomonomyProfile = this.stockObjectBase as ITradeEconomyProfile;

                return true;
            }

            return false;



        }

        public  bool Create_TestData(string id)
        {
            this.stockObjectBase.ID = id;
            return Create_TestData();

        }
      
        public override bool Create_TestData()
        {

            base.Create_TestData();

            this.tradeEcomonomyProfile.Date_Start = new DateTime(1950, 1, 1);
            this.tradeEcomonomyProfile.Number_Bonds = 10;
            this.tradeEcomonomyProfile.Number_Shares = 30;

            
            



            
            CreateStatusItems();




            //
            //PortfolioFactory pf = new PortfolioFactory();


            this.tradeEcomonomyProfile.PortfolioNames = PortfolioFactory.Create_PortfolioNames();
            return true;

        }

        
        private bool CreateStatusItems()
        {
            tradeEcomonomyProfile.EconomyStatusCollection = new System.Collections.ArrayList();

            IEconomyStatus es = new EconomyStatus();
            es.Date = this.tradeEcomonomyProfile.Date_Start;
            es.Percentage_Bonds_00 = 6;
            es.Percentage_Bonds_05 = 8;
            es.Percentage_Bonds_30 = 9;
            es.Percentage_Inflation = 5;

            es.Percentage_Overall = 10;
            es.Percentage_Productivity = 5;
            es.Percentage_Shares = 9;

            
            tradeEcomonomyProfile.EconomyStatusCollection.Add(es);

            es = new EconomyStatus();
            es.Date = new DateTime(1955,5,2);
            es.Percentage_Bonds_00 = 4;
            es.Percentage_Bonds_05 = 5;
            es.Percentage_Bonds_30 = 6;
            es.Percentage_Inflation = 3;

            es.Percentage_Overall = 6;
            es.Percentage_Productivity = 3;
            es.Percentage_Shares = 5;
            tradeEcomonomyProfile.EconomyStatusCollection.Add(es);
            //------------------------------
            es = new EconomyStatus();
            es.Date = new DateTime(1960, 12, 2);
            es.Percentage_Bonds_00 = 4.5F;
            es.Percentage_Bonds_05 = 5.5F;
            es.Percentage_Bonds_30 = 7;
            es.Percentage_Inflation = 3.5F;

            es.Percentage_Overall = 3;
            es.Percentage_Productivity = 1;
            es.Percentage_Shares = -2;
            tradeEcomonomyProfile.EconomyStatusCollection.Add(es);
            //------------------------------
            //------------------------------
            es = new EconomyStatus();
            es.Date = new DateTime(1963, 6, 3);
            es.Percentage_Bonds_00 = 3.5F;
            es.Percentage_Bonds_05 = 4;
            es.Percentage_Bonds_30 = 4;
            es.Percentage_Inflation = 2;

            es.Percentage_Overall = 4;
            es.Percentage_Productivity = 0;
            es.Percentage_Shares = -5;


            tradeEcomonomyProfile.EconomyStatusCollection.Add(es);

            return true;

        }
      
    }
}
